<template>
   <div>
    <MyHeader title="购物车案例"></MyHeader>
    <div class="main">
      <MyGoods :goods="list"></MyGoods>
    </div>
    <MyFooter :list="list" @changeAll="changeAll"></MyFooter>
  </div>
</template>

<script>
import axios from 'axios'
import MyHeader from './components/MyHeader'
import MyGoods from './components/MyGoods'
import MyFooter from './components/MyFooter'
export default {
  components: {
    MyHeader,
    MyGoods,
    MyFooter
  },
  data() {
    return {
      list:[],
    }
  },
   async created(){
   const {data}=await axios.get('https://www.escook.cn/api/cart')
   console.log(data.list);
   this.list=data.list
   
  },
   methods:{
    changeAll(val){
      console.log(val);
      this.list.forEach(item=>item.goods_state=val)
    }
  }

}
</script>

<style>
  .main{
    padding-top: 45px;
    padding-bottom: 50px;
  }
</style>